System.Management.ManagementExcept ion Shutting down
Hi ,
Can any one help with this kind of exception.
Error Type: System.Reflection.TargetInvocationException System.Management.ManagementException Error Time: 23/05/2011 11:27:25 Technical Error Message: Exception has been thrown by the target of an invocation. Shutting
down
This exception is not continuous for us . we are trying to give bulk prints at that time query for the printer is causing the problem. my snipet as follows. please let us know how can we resolve this.
ManagementScope scope = new ManagementScope(ManagementPath.DefaultPath);
scope.Connect();
scope.Options.EnablePrivileges = true;
createQuery = new WqlEventQuery();
connString = ConfigurationManager.ConnectionStrings["Phoenix"].ConnectionString;
timeinterval = ConfigurationManager.AppSettings["PollingIntervalInSeconds"];
printerNames = ConfigurationManager.AppSettings["PrinterNames"];
userName = ConfigurationManager.AppSettings["UserName"];
sqlConn = new SqlConnection(connString);
txtStatus.Text = string.Empty;
//WMI Job notification query. To trap job creation events.
createQuery.QueryString = "SELECT * FROM __InstanceCreationEvent "
+ "WITHIN " + timeinterval + " WHERE " +
"TargetInstance ISA \"Win32_PrintJob\" AND TargetInstance.Owner = '" + userName + "' AND" +
" TargetInstance.Name LIKE '%" + printerNames + "%'";
createWatcher = new ManagementEventWatcher(scope, createQuery);
createWatcher.EventArrived += new EventArrivedEventHandler(createWatcher_EventArrived);
createWatcher.Start();
Any early would be great ,
Thanks inadvance
May 23rd, 2011 9:01am
Is this a CM07 question? I'm not sure why edhickey move this thread.http://www.enhansoft.com/
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2011 12:32pm